﻿using System;
using System.Drawing;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using MailServer.Properties;

namespace MailServer
{
    public partial class MailServerForm : Form
    {
        private readonly IMailServer _mailServer;

        public MailServerForm()
        {
            InitializeComponent();

            buttonStop.Enabled = false;
            labelServerStatus.Text = Resources.serverStoped;
            labelServerStatus.ForeColor = Color.Red;
            _mailServer = new MailServer(9999);
        }

        private void buttonStart_Click(object sender, EventArgs e)
        {
            labelServerStatus.Text = Resources.serverStarted;
            buttonStop.Enabled = true;
            labelServerStatus.ForeColor = Color.Green;
            Task.Factory.StartNew(()=>_mailServer.Start());
        }

        private void buttonStop_Click(object sender, EventArgs e)
        {
            labelServerStatus.Text = Resources.serverStoped;
            buttonStop.Enabled = false;
            labelServerStatus.ForeColor = Color.Red;
            _mailServer.Stop();
        }
    }
}





